package com.yuanian.timingwheel.config;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.sql.DataSource;

@Component
public class JobConfig implements InitializingBean {

    private static JobConfig jobConfig = null;
    public static JobConfig getInstance() {
        return jobConfig;
    }

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Resource
    private DataSource dataSource;

    public DataSource getDataSource() {
        return dataSource;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        jobConfig = this;
    }

    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }
}
